<?php

class Login extends Controller {

	function Login() {
		parent::Controller();
		
	}
	
	function index() {
        $this->load->library('simplepie');
        $this->load->model('Arsip_model', 'p');
        
        $data['list_data'] = $this->p->list_publik();
        $data['arsip_baru'] = $this->p->arsip_baru();
    
        $data['feed'] = new SimplePie();
        $data['feed']->set_feed_url('http://www.dilmil-bandung.go.id/portal/feed/feeder');
        $data['feed']->enable_cache(false);
        $data['feed']->init();
            
        $this->load->view('login',$data);
    }

    function masuk($nama_user, $passwd) {
        $this->load->model('Login_model', 'l');

        if ($this->l->isValidLogin($nama_user, $passwd)) {
            $data = array(
                'username' => $nama_user,
                'role' => $this->l->getRole($nama_user)
            );
            $this->session->set_userdata($data);

            //redirect("welcome", "refresh");
            echo "sukses";
        } else {
            //redirect("login", "refresh");
            echo "not-sukses";
        }
    }
    
    function keluar() {
        $this->session->sess_destroy();
        redirect("login", "refresh");
    }

}

/* End of file login.php */
/* Location: ./system/application/controllers/login.php */